<html>
<head>
<title>Cotizadores</title>
<script src="http://bit.ly/jqymin"></script>
<style>
textarea {
width: 80%;
height: 50%;
overflow-x: scroll;
overflow-y: scroll;
display: block;
border: 1px solid black;
padding: 5px;
margin: 5px;
}
</style>
    <script>
      function formatXml(xml) {
        var formatted = '';
        var reg = /(>)(<)(\/*)/g;
        xml = xml.replace(reg, '$1\r\n$2$3');
        var pad = 0;

        jQuery.each(xml.split('\r\n'), function(index, node) {
          var indent = 0;
          if (node.match( /.+<\/\w[^>]*>$/ )) {
            indent = 0;
          } else if (node.match( /^<\/\w/ )) {
            if (pad != 0) {
              pad -= 1;
            }
          } else if (node.match( /^<\w[^>]*[^\/]>.*$/ )) {
            indent = 1;
          } else {
            indent = 0;
          }
          
          var padding = '';
          for (var i = 0; i < pad; i++) {
            padding += '  ';
          }
          
          formatted += padding + node + '\r\n';
          pad += indent;
        });

        return formatted;
      }
      
      $(function() {
        var i;
        
        for(i = 0; i < 10; i++) {
          if(document.getElementById('xmlNode' + i)) {
            document.getElementById('xmlNodeF' + i).value = formatXml(document.getElementById('xmlNode' + i).innerHTML);
            document.getElementById('xmlNode'  + i).style.display = "none";
          }
        }
      });
    </script>
  </head>
  <body>
    
